package com.app.web.user.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Autowried;
import org.springframework.context.annotation.Controller;
import org.springframework.context.annotation.RequestMapping;
import org.springframework.context.annotation.RequestParam;

import com.app.web.user.service.UserService;


@Controller
@RequestMapping("user")
public class UserController {
	
	@Autowried
	private UserService userService;
	
	
	@RequestMapping("login")
	public void login(HttpServletRequest request, HttpServletResponse response, @RequestParam("name") String name, @RequestParam("pwd") String pwd){
		
		try {
			PrintWriter out = response.getWriter();
			String result = userService.login(name, pwd);
			if (result != null) {
				out.write(result+"\n");
			}else {
				out.write("hello world：name="+name+"\t pwd="+pwd);
			}
			
			out.flush();
			out.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
